﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TempUIPanel : MonoBehaviour {
    public static TempUIPanel _instance;
    private Transform showMsgsPanel;
    private Transform temperature;
    private Transform hum;
    private Transform airPressure;
    private Transform windDir;
    private Transform averagewind;
    private Transform maxwind;

    private void Awake()
    {
        _instance = this;
    }
    void Start () {
        showMsgsPanel = transform.Find("ShowMsgsPanel");
        temperature = showMsgsPanel.Find("temperature");
        hum = showMsgsPanel.Find("humidity");
        airPressure = showMsgsPanel.Find("airpressure");
        windDir= showMsgsPanel.Find("winddirection");
        averagewind = showMsgsPanel.Find("averagewind");
        maxwind = showMsgsPanel.Find("maxwind");
    }
    /// <summary>
    /// 显示温度数据
    /// </summary>
    /// <param name="value"></param>
    public void SetTemperatureUI( float value) {
        value = Mathf.Clamp( value,-50.0f,50.0f);
        temperature.GetComponentInChildren<Slider>().value = value;
        temperature.Find("Value").GetComponent<Text>().text = value.ToString();
    }
    /// <summary>
    /// 显示湿度UI
    /// </summary>
    /// <param name="value"></param>
    public void SetHumidityUI( float value) {
        hum.GetComponentInChildren<Slider>().value = value;
        hum.Find("Value").GetComponent<Text>().text = value.ToString();
    }
    /// <summary>
    /// 显示气压UI
    /// </summary>
    /// <param name="value"></param>
    public void SetAirPressureUI( float value) {
        value = Mathf.Clamp( value, 0.0f, 200.0f );
        airPressure.GetComponentInChildren<Slider>().value = value;
        airPressure.Find("Value").GetComponent<Text>().text = value.ToString();
    }
    /// <summary>
    /// 显示风向
    /// </summary>
    /// <param name="value"></param>
    public void SetWindDir(string value) {
        windDir.Find("Value").GetComponent<Text>().text = value.ToString();
    }
    /// <summary>
    /// 显示平均风速
    /// </summary>
    /// <param name="value"></param>
    public void SetAverageWind(float value) {
        averagewind.Find("Value").GetComponent<Text>().text = value.ToString();
    }
    /// <summary>
    /// 显示最大风速
    /// </summary>
    /// <param name="value"></param>
    public void SetMaxWind(float value) {
        value = Mathf.Clamp( value, 0.0f, 100.0f );
        maxwind.Find("Value").GetComponent<Text>().text = value.ToString();
    }
}
